<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pm="http://primefaces.org/mobile"
	template="/templates/mobileTemplate.xhtml">
	
	<f:metadata>
		<f:event type="preRenderView"
			listener="#{processoMobileBean.initConversation}" />
		<f:event type="preRenderView"
			listener="#{processoMobileBean.carregarNotificacoes}" />
	</f:metadata>
	
	<ui:define name="javascript">
		<script>
			$(document).bind("mobileinit", function(){
				$.mobile.defaultPageTransition = 'flow';
				$.mobile.selectmenu.prototype.options.nativeMenu = false;
			});
		</script>
	</ui:define>
	
	<ui:define name="content">
	
		<!-- Main View -->
		<pm:view id="processoList">
			<pm:header title="#{msg['label.aplicacao.nome']}">
                <f:facet name="left"><p:button value="#{msg['botao.sair']}" icon="signout" outcome="sair" /></f:facet>
                <pm:navBar>
                	<p:button value="#{msg['tab.home']}" icon="home" styleClass="ui-btn-active" />
                	<p:button value="#{msg['tab.pesquisar']}" icon="search" outcome="pesquisar" />
                	<p:button value="#{msg['tab.configuracoes']}" icon="gear" outcome="configuracoes" />
                </pm:navBar>
            </pm:header>

            <pm:content>
            	<h:form id="notificacaoListForm">
					<p:commandButton value="#{msg['processo.botao.incluir']}" icon="plus" action="#{processoMobileBean.criar}" 
						update=":processoEditForm" styleClass="ui-btn ui-mini" />
						
					<pm:content rendered="#{not empty processoMobileBean.notificacoes}">
						<div align="left">
		            		<h4>#{msg['processo.titulo.listaNotificacoes']}:</h4>
		            	</div>
		            	<div>#{msg['processo.mensagem.cliqueParaVisualizar']}</div>
		            	<br />
						<p:dataList type="inset" value="#{processoMobileBean.notificacoes}" var="notificacao" styleClass="ui-mini">
							<f:attribute name="filter" value="true" />
							<p:column >
						        <p:commandLink value="#{notificacao.notificacao.processo.npu}" action="#{processoMobileBean.visualizarNotificacao}">
						        	<f:setPropertyActionListener value="#{notificacao}" target="#{processoMobileBean.notificacao}" />
						            <f:setPropertyActionListener value="#{notificacao.notificacao.processo}" target="#{processoMobileBean.entidade}" />
						        </p:commandLink>
						    </p:column>
						</p:dataList>
					</pm:content>
				</h:form>              
            </pm:content>
		</pm:view>
		
		<!-- Main View -->
		<pm:view id="processoEdit">
			<pm:header title="#{msg['label.aplicacao.nome']}">
                <f:facet name="left"><p:button value="#{msg['botao.sair']}" icon="signout" outcome="sair" /></f:facet>
                <pm:navBar>
                	<p:button value="#{msg['tab.home']}" icon="home" styleClass="ui-btn-active" />
                	<p:button value="#{msg['tab.pesquisar']}" icon="search" outcome="pesquisar" />
                	<p:button value="#{msg['tab.configuracoes']}" icon="gear" outcome="configuracoes" />
                </pm:navBar>
            </pm:header>

            <pm:content>
            	<div align="left">
	           		<h4>#{msg['processo.titulo.dados']}:</h4>
	           	</div>
            	<h:form id="processoEditForm">
					<p:messages />

					<pm:field>
						<h:outputLabel for="tribunal" value="#{msg['processo.tribunal']}" />
						<h:selectOneMenu value="#{processoMobileBean.entidade.tribunal}" id="tribunal"
							converter="viewMapEntityConverter" var="sItem">
							<f:selectItems value="#{processoMobileBean.tribunais}" var="tribunal" 
								itemLabel="#{tribunal.sigla}" itemValue="#{tribunal}" />
						</h:selectOneMenu>
						<p:message for="tribunal" />
					</pm:field>

					<p:selectOneRadio id="tipoJuizo" value="#{processoMobileBean.entidade.tipoJuizo}" 
							label="#{msg['processo.tipoJuizo']}">
						<f:selectItem itemLabel="#{msg['processo.tipoJuizo.1g']}" itemValue="PRIMEIRO_GRAU" />
						<f:selectItem itemLabel="#{msg['processo.tipoJuizo.2g']}" itemValue="SEGUNDO_GRAU" />
					</p:selectOneRadio>

					<p:inputText value="#{processoMobileBean.entidade.npu}" id="npu" label="#{msg['processo.npu']}" />
					<p:message for="npu" />
					
					<p:commandButton value="#{msg['botao.salvar']}" icon="check" 
						action="#{processoMobileBean.salvar}" 
						update=":notificacaoListForm,:processoEditForm" />
					<p:button value="#{msg['botao.cancelar']}" icon="delete" 
						href="#processoList" />
				</h:form>              
            </pm:content>
		</pm:view>
		
	</ui:define>
</ui:composition>